//package cn.com.lms.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//@Configuration
//public class WebMvcConfig implements WebMvcConfigurer {
//
//    private static final String PATTERN = "/**";  //全局路径
//
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping(PATTERN)  //映射范围
//                .allowedOrigins("*")  //允许的域名
//                .allowedHeaders("*")
//                .allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE","OPTIONS", "TRACE");
//    }
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        InterceptorRegistration registration = registry.addInterceptor(accessInterceptor());
//        registration.excludePathPatterns("/error");  //添加不拦截路径
//        registration.excludePathPatterns("/static/**");
//        registration.excludePathPatterns("/user/login");
//        registration.excludePathPatterns("/course/upload");
//        registration.excludePathPatterns("/swagger-ui/**");
//        registration.excludePathPatterns("/swagger-ui.html");
//        registration.addPathPatterns(PATTERN);  //所有路径都被拦截
//    }
//
//    @Bean
//    public AccessInterceptor accessInterceptor() {
//        return new AccessInterceptor();
//    }
//
//}
